export default {
    name: "app",
    data() {
        return {
            activeName: 'inquire',
            // 仓库选项
            warehouseList: [],
            // 查询
            inquire:
            {
                warehouseName: '',
                rid: '',
                minTime: '',
                maxTime: '',
                operation: 1,
            },
            tableColumnList: [],
            showList: [],
            // 分页
            currentPage: 1,
            total: 0,
            pageSize: 7,
            // 选中行信息
            row: '',
        }
    },
    created() {
        // 清空
        // this.inquire = {
        //     warehouseName: '',
        //     rid: '',
        //     minTime: '',
        //     maxTime: '',
        //     operation: 1,
        // }
        this.get_warehouses()
        this.search_order()
    },
    methods: {
        //对el-table的表头，表格的样式进行设置
        tableHeaderCellStyle() {
            return 'background-color: #2c9678; color: #ffffff; border-color: white;'
        },
        tableCellStyle() {
            return 'border-color: #2c9678;'
        },
        // 页数变化
        handleCurrentChange(val) {
            this.currentPage = val;
        },
        async get_warehouses() {
            // 调用接口
            const { data: res } = await this.$http.get('/gim/api/admin/manageWarehouse/selectWarehouse/allWarehouse');
            // 获取成功
            if (res.code == 1)
                this.warehouseList = res.response
            else
                this.$store.commit('error', '获取仓库列表信息失败')
        },
        // 查询入库单
        async search_order() {
            this.inquire.minTime = this.$moment(this.inquire.minTime).valueOf();
            this.inquire.maxTime = this.$moment(this.inquire.maxTime).valueOf();

            const inquire = this.$qs.parse(this.inquire)
            const { data: res } = await this.$http.post('/gim/api/admin/manageInventoryRecord/selectInventoryRecord', inquire);
            // 获取成功
            if (res.code == 1) {
                this.tableColumnList = res.response.tableColumnList
                this.showList = res.response.inventoryRecordList
                this.total = res.response.totalNum
            }
            else if (res.code == 502)
                this.$store.commit('error', res.msg)
            else {
                this.showList = []
                this.total = 0
                this.$store.commit('error', res.response)
            }
        },

        // 前往明细页面
        to_inbound_order_detail(row, event, column) {
            //还有一种情况就是，如果通过 query 的方式传递对象或数组，在地址栏中会被强制转换成 [object Object]，刷新后也获取不到对象值。
            // 此时可以通过 JSON.stringify() 方法将要传递的参数转换为字符串传递，在详情页再通过 JSON.parse() 转换成对象。
            this.row = this.$qs.stringify(row)
            window.sessionStorage.setItem("boundstate", "check")
            // this.$router.push({ path: "/inbound_order_detail", query: { detail: row } });
            this.$router.push({
                path: "/inbound_order_detail",
                query: { detail: this.row }
            })

        },

        add_order() {
            window.sessionStorage.setItem("boundstate", "add")
            this.$router.push("/inbound_order_detail")
        },
    },
}